<!--
 * @Author: zhoujinlong 765637726@qq.com
 * @Date: 2024-03-26 09:15:20
 * @LastEditors: zhoujinlong 765637726@qq.com
 * @LastEditTime: 2024-03-26 09:44:49
 * @FilePath: \election-yd\src\renderer\src\pages\test\test.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
 
<template>
  <div>
    test
  </div>
</template>

<script setup lang="ts">
import { desktopCapturer } from 'electron'
import { onMounted } from 'vue'

onMounted(() => {
  desktopCapturer
    .getSources({ types: ['window', 'screen'], thumbnailSize: { width: 1280, height: 720 } })
    .then(async (sources) => {
      for (const source of sources) {
        if (source.name === 'Entire Screen') {
          try { 
            const screenshot = source.thumbnail.toDataURL()
            // 这里你可以将截取到的图片显示到界面上，或者保存等操作
            console.log(screenshot) // 打印图片的base64编码
          } catch (e) {
            console.error(e)
          }
        }
      }
    })
})
</script>  

<style scoped>
</style> 